package com.ruoyi.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.domain.zbg.AnnualPlanData;
import com.ruoyi.system.domain.zbg.CostData;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface CostDataMapper extends BaseMapper<CostData> {
    // 这里可以添加自定义的查询方法
    int insert(@Param("costData") CostData costData);

    AnnualPlanData selectByYear( @Param("currentYear") int currentYear);
    @Insert("<script>" +
            "INSERT INTO cost_data (district, repair_quota, repair_used, electric_quota, electric_used, tower_quota, tower_used, network_quota, network_used, compensation_quota, compensation_used, cost_year, cost_month) " +
            "VALUES (#{costData.district}, #{costData.repairQuota}, #{costData.repairUsed}, #{costData.electricQuota}, #{costData.electricUsed}, #{costData.towerQuota}, #{costData.towerUsed}, #{costData.networkQuota}, #{costData.networkUsed}, #{costData.compensationQuota}, #{costData.compensationUsed}, #{costData.costYear}, #{costData.costMonth}) " +
            "ON DUPLICATE KEY UPDATE " +
            "repair_quota = VALUES(repair_quota), " +
            "repair_used = VALUES(repair_used), " +
            "electric_quota = VALUES(electric_quota), " +
            "electric_used = VALUES(electric_used), " +
            "tower_quota = VALUES(tower_quota), " +
            "tower_used = VALUES(tower_used), " +
            "network_quota = VALUES(network_quota), " +
            "network_used = VALUES(network_used), " +
            "compensation_quota = VALUES(compensation_quota), " +
            "compensation_used = VALUES(compensation_used)" +
            "</script>")
    int saveOrUpdate(@Param("costData") CostData costData);
    //查询当年实际维修费的使用情况
    Double countCostByAreaAndYear(@Param("year") int year, @Param("areaName") String areaName);
    //查询每当年实际电费的使用情况
    Double countElectricCostByAreaAndYear(@Param("year") int year, @Param("areaName") String areaName);
//获取当年塔费的实际使用情况
    Double selectCountByAreaAndYear(@Param("year") int year, @Param("areaName") String areaName);
//获取当年网络费的使用情况
    Double selctnetworkProductCountByAreaAndYear( @Param("year") int year,@Param("areaName") String areaName);
//获取当年赔补的使用情况
    Double selectCompensationCountByAreaAndYear(@Param("year") int year,@Param("areaName") String areaName);
}